<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>意见列表</title>
<link rel="stylesheet" type="text/css"
	href="/bsc/static/common/bootstrap/css/bootstrap.min.css" />
<script src="/bsc/static/js/jquery-3.1.1.js" type="text/javascript"
	charset="utf-8"></script>
<script
	src="/bsc/static/common/bootstrap/js/bootstrap-3.3.7-dist/js/bootstrap.min.js"
	type="text/javascript" charset="utf-8"></script>
<script
	src="/bsc/static/common/bootstrap/js/bootstarp-table-1.11.1/bootstrap-table.min.js"
	type="text/javascript" charset="utf-8"></script>
<script
	src="/bsc/static/common/bootstrap/js/bootstarp-table-1.11.1/bootstrap-table-zh-CN.min.js"
	type="text/javascript" charset="utf-8"></script>
 <!-- <link rel="stylesheet" type="text/css"
	href="/bsc/static/common/layui/css/layui.css" media="all">  -->  
  
<link rel="stylesheet" type="text/css"
	href="../static/common/global.css" media="all">
<link rel="stylesheet" type="text/css" href="../static/css/personal.css"
	media="all">
<script type="text/javascript">
$(document).ready(function() {
    /*全选与反选按钮*/
    $("#all").click(function() {
        var state = $("#all").prop("checked");
        if(state == true) {
            $("[name='option']").prop("checked", "checked");
        } else {
            $("[name='option']").prop("checked", "");
        }
    }); 
    /*------------------------------------------------------------------------------------*/
    /*根据复选框是否全部选中来判断全选框是否选中*/
    //获取当前页面数据条数
    var options = $("[name='option']");
    //给每一个复选框加上click事件
    $("input[name='option']").click(function() {
        //获取当前选中的复选框个数
        var i = $("input[name='option']:checked");
        //判断复选框选中个数是否等于当前页面数据条数
        if(i.length == options.length) { //如果两者值相等那么全选按钮也会选中
            $("#all").prop("checked", "checked");
        } else { //当两者值不相等时全选框便不会显示选中
            $("#all").prop("checked", "");
        }
    });
    $(document).ready(function() {
				$("#delBtn").click(function(obj) {//绑定
									var array = "";
									var num = document.getElementsByName("option");
									for (var i = 0; i < num.length; i++) {
										if (num[i].checked) {
											array += num[i].value + ",";
										}
									}
									if (array.length > 0) {
										array = array.substring(0,array.length - 1);
										document.forms[0].action = "/bsc/bisopinion/delete?ids="+ array;
										document.forms[0].submit();
									} else {
										alert("你还未选取数据");
									}
								});
				
			});
	
    $("#btn").click(function() {//绑定
		var opinion_id='';	
	  var count=0;
		var num = document.getElementsByName("option");
		for (var i = 0; i < num.length; i++) {
		if (num[i].checked) {
		  count++;
		  opinion_id=num[i].value;
		}
		}
		if(count==0){
			alert("请选择要查看的内容");
		}else if(count>1){
			alert("查看详情时只能选择一个");
		}else{
			$("#myModal").modal("show");
			$.post("/bsc/bisopinion/select?opinion_id="+opinion_id,function(msg){
				var a=eval("("+msg+")");
				var time=new Date(a.create_time);
				
				$("#content").val(a.content);
				$("#username").val(a.bis_custom_user.username);
				$("#create_time").val(formatDateTime(time));
				
			});
		}
	});
    $("#close").click(function(){
		$("#content").val("");
		$("#myModal").modal("hide");
	})
	$("#chax").click(function(){
		formName.action="/bsc/bisopinion/list";
		formName.submit();
	})
});

</script>
</head>

<body>
	<form class="form-inline" role="form" id="formName" method="post">
		<section class="layui-larry-box">
		<blockquote class="layui-elem-quote news_search">
			<table>
				<tr>
					<td>
						<div class="form-group">
							<label>手机号码：</label><input type="text"
								style="width: 150px; height: 30px" class="form-control"
								name="mobile" placeholder="请输入手机号码" value="" id="">
						</div>
					</td>
					<td>
						<div class="form-group">
							<label for="content">内容：</label> <input type="text"
								class="form-control" name="content" placeholder="请输入内容">
						</div>
					</td>
					<td>
						<div class="form-group">
							<label for="create_time1"> 发送日期：</label> <input type="date"
								class="form-control" name="create_time1" placeholder="">
						</div>
						<div class="form-group">
					</td>
					<td>
						<div class="form-group">
							<label for="create_time2"> 至：</label> <input type="date"
								class="form-control" name="create_time2" placeholder="">
						</div>
					</td>
					<td><button type="butten" class="btn btn-info glyphicon glyphicon-search" id="chax" value="查询">查询</button>
					 <button type="reset" class="btn btn-danger glyphicon glyphicon-refresh " value="重置">重置</button><br></td>
				</tr>
			</table>
		</blockquote>
		<div class="layui-form news_list">
			<table class="table table-hover table-bordered ">
				<colgroup>
					<col width="5%">
					<col width="15%">
					<col width="65%">
					<col width="15%">
				</colgroup>
				<thead>
					<tr class="active">
						<td colspan="4">
						<input type="button" value="查看详情" id="btn" class="btn btn-info" style="height: 35px;" /> 
						<input type="button" value="删除" id="delBtn" class="btn btn-danger " style="height: 35px;">
						</td>
					</tr>
					<tr class="active">
						<td class="text-center"><input type="checkbox" id="all">全选</td>
						<td class="text-center">手机号码</td>
						<td class="text-center">内容</td>
						<td class="text-center">发送时间</td>
					</tr>
				</thead>
				<tbody class="news_content">
					<c:forEach items="${info.list}" var="opinion">
						<tr>
							<td class="text-center"><input type="checkbox" name="option"
								value="${opinion.opinion_id}"></td>
							<td class="text-center">${opinion.bis_custom_user.mobile}</td>
							<td class="text-center">${opinion.content }</td>
							<td class="text-center"><fmt:formatDate
									value="${opinion.create_time }" pattern="yyyy-MM-dd hh:mm:ss" /></td>
						</tr>
					</c:forEach>
				</tbody>
			</table> 
			<a href="#" class="btn btn-link glyphicon glyphicon-backward"
				onclick="up()">上一页</a> <a
				class="btn btn-link glyphicon glyphicon-forward" href="#"
				onclick="next()">下一页</a>
		</div>
		</section>
	</form>
	<div class="modal fade bs-example-modal-lg" id="myModal" tabindex="-1"
		role="dialog" aria-labelledby="myModalLabel" width="100%">
		<div class="modal-dialog" role="document">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal"
						aria-label="Close">
						<span aria-hidden="true">&times;</span>
					</button>
					<h4 class="modal-title" id="myModalLabel">意见信息</h4>
				</div>
				<div class="modal-body">
					<table width="100%">
					<tr>
			      		<td class="text-center"><h5><label>发送人:</label></h5></td>   
			      		<td class="text-center"><input class="form-control Default input" type="text" id="username" placeholder="Default input" readonly="readonly"/></td>  
         			 </tr>
						<tr>
							<td class="text-center"><h5>
									<label>发送内容:</label>
								</h5></td>
							<td class="text-center"><input class="form-control Default input"
								type="text" id="content" placeholder="Default input" readonly="readonly" /></td>
						</tr>
						<tr>
			      		<td class="text-center"><h5><label>发送时间:</label></h5></td>   
			      		<td class="text-center"><input class="form-control Default input" type="text" id="create_time" placeholder="Default input" readonly="readonly"/></td>  
         			 </tr>
					</table>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-danger glyphicon glyphicon-remove" data-dismiss="modal">关闭</button>
				</div>
			</div>
		</div>
	</div>

	<script type="text/javascript">
//上一页
function up(){
	document.forms[0].action="/bsc/bisopinion/list?page="+${info.prePage};
	document.forms[0].submit();
};
//下一页
function next(){
	document.forms[0].action="/bsc/bisopinion/list?page="+${info.nextPage};
	document.forms[0].submit();
};
//时间格式
function formatDateTime(inputTime) {  
    var date = new Date(inputTime);
    var y = date.getFullYear();  
    var m = date.getMonth() + 1;  
    m = m < 10 ? ('0' + m) : m;  
    var d = date.getDate();  
    d = d < 10 ? ('0' + d) : d;  
    var h = date.getHours();
    h = h < 10 ? ('0' + h) : h;
    var minute = date.getMinutes();
    var second = date.getSeconds();
    minute = minute < 10 ? ('0' + minute) : minute;  
    second = second < 10 ? ('0' + second) : second; 
    return y + '-' + m + '-' + d+' '+h+':'+minute+':'+second;  
};
</script>
</body>
</html>